#!/bin/bash


prefixDir="/usr/local"
installDir="${prefixDir}/pemd"
upgradeInstallDir="${prefixDir}/upgrade"
monitorInstallDir="${prefixDir}/monitor"
ldconfigFile="/etc/ld.so.conf.d/pemd.conf"
serviceFile="/etc/systemd/system/pemd.service"
upgradeServiceFile="/etc/systemd/system/upgrade.service"
monitorServiceFile="/etc/systemd/system/monitor.service"

echo "stop pemd..."
sudo systemctl stop pemd

echo "stop upgrade..."
sudo systemctl stop upgrade

echo "stop monitor..."
sudo systemctl stop monitor

echo "uninstall pemd..."
if [ -d ${installDir} ]; then
    sudo rm -rf ${installDir}/bin
    sudo rm -rf ${installDir}/lib
    sudo rm -rf ${installDir}/module
    sudo rm -rf ${upgradeInstallDir}/upgrade
    sudo rm -rf ${monitorInstallDir}
fi

sudo rm -rf ${ldconfigFile}
sudo rm -rf ${serviceFile}
sudo rm -rf ${upgradeServiceFile}
sudo rm -rf ${monitorServiceFile}


